// 用于列表的渲染
<template>
  <div>
    <el-table :data="memberList" border style="width: 100%">
      <el-table-column prop="uid" label="用户编号" width="180">
      </el-table-column>
      <el-table-column prop="nickname" label="昵称" width="180">
      </el-table-column>
      <el-table-column prop="phone" label="手机号"> </el-table-column>
      <el-table-column label="状态" prop="status">
        <template slot-scope="item">
          <!-- tag标签 -->
          <div>
            <el-tag v-if="item.row.status == 1" type="success">启 用</el-tag>
            <el-tag v-else type="danger">禁 用</el-tag>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="item">
          <div>
            <el-button
              type="primary"
              size="small"
              @click="edit(item.row.uid)"
              round
              >编辑</el-button
            >
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { mapActions, mapGetters } from "vuex";
export default {
  data() {
    return {};
  },
  computed: {
    ...mapGetters({
      memberList: "member/getMemberList"
    })
  },
  mounted() {
    //当列表渲染触发行动
    this.getMemberAction();
  },
  methods: {
    ...mapActions({
      getMemberAction: "member/getMemberListAction"
    }),
    // 封装一个编辑事件
    edit(id) {
      // 告诉父组件，要打开编辑弹框顺便传一个id
      this.$emit("edit", id);
    }
  }
};
</script>

<style lang="" scoped></style>
